package com.xb.cloud.shopping.client;

import java.util.Map;
import java.util.TreeMap;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.xb.cloud.gateway.client.Adapter;
import com.xb.cloud.gateway.client.AdapterContext;
import com.xb.cloud.gateway.client.Context;
import com.xb.cloud.gateway.client.ReturnUtils;
import com.xb.cloud.gateway.client.RtnInfo;
import com.xb.cloud.shopping.service.PaymentApiService;

@Component
public class PaymentNotifyAdapter extends Adapter {

	@Resource
	PaymentApiService paymentApiService;

	@Override
	public RtnInfo execute(String urlPath, Boolean isLogined, Map<String, String> bizInfo, AdapterContext context) {

		Map<String, String> params = new TreeMap<String, String>();
		params.putAll(bizInfo);

		RtnInfo rtnInfo = paymentApiService.checkPaymentNotify(params);
		if (ReturnUtils.isSuccess(rtnInfo)) {
			((Context) context).setRtnText("notify_success");
		}

		return rtnInfo;
	}

	@Override
	public String getUrlMappingPath() {
		return "/h5/shopping/payment/notify";
	}

}
